from torch import nn


class MyModel1(nn.Module):
    def __init__(self, num_classes=75, dropout=0.5):
        super(MyModel1, self).__init__()
        self.conv1 = nn.Conv2d(in_channels=3, out_channels=32, kernel_size=3, padding=0)
        self.pool1 = nn.MaxPool2d(kernel_size=2, stride=2)
        self.conv2 = nn.Conv2d(in_channels=32, out_channels=64, kernel_size=3, padding=0)
        self.pool2 = nn.MaxPool2d(kernel_size=2, stride=2)
        self.flatten = nn.Flatten()
        self.drop1 = nn.Dropout(p=dropout)
        self.fc1 = nn.Linear(186624, 150)
        self.drop2 = nn.Dropout(p=dropout)
        self.fc2 = nn.Linear(150, 100)
        self.fc3 = nn.Linear(100, num_classes)

    def forward(self, x):
        x = self.pool1(nn.ReLU()(self.conv1(x)))
        x = self.pool2(nn.ReLU()(self.conv2(x)))
        x = self.flatten(x)
        x = self.drop1(x)
        x = nn.ReLU()(self.fc1(x))
        x = self.drop2(x)
        x = nn.ReLU()(self.fc2(x))
        x = self.fc3(x)  # 使用 Softmax 作为最后一层的激活函数
        return x